package com.tj.view;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.tj.view.activity.CustomImageActivity;
import com.tj.view.activity.DisplayShotActivity;
import com.tj.view.activity.FlowLayoutActivity;
import com.tj.view.activity.FlyAnimatorActivity;
import com.tj.view.activity.LoadingAnimaActivity;
import com.tj.view.activity.MarqueeActivity;
import com.tj.view.activity.MyCardActivity;
import com.tj.view.activity.NumberProgressActivity;
import com.tj.view.activity.TsCanvasActivity;
import com.tj.view.activity.TsWindowMangerActivity;
import com.tj.view.tool.DisplayUtil;
import com.tj.view.view.AutoScrollTextView;

import butterknife.Bind;
import butterknife.ButterKnife;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private static final String TAG = "MainActivity";

    @Bind(R.id.tv_argument) TextView mTv_argument;
    @Bind(R.id.tv_marguee_view) TextView mTv_marqueeview;
    @Bind(R.id.tv_Notice) AutoScrollTextView mTv_notice;
    @Bind(R.id.tv_numberProgress_view) TextView mTv_numberprogress;
    @Bind(R.id.tv_mycard_view) TextView mTv_mycardview;
    @Bind(R.id.tv_flowlayout_view) TextView mTv_flowlayout_view;
    @Bind(R.id.tv_display_view) TextView mTv_display_view;
    @Bind(R.id.tv_customimage_view) TextView mTv_customImage_view;
    @Bind(R.id.tv_animation_loading) TextView mTv_animation_loading;
    @Bind(R.id.tv_canvas_draw) TextView mTv_canvas_draw;
    @Bind(R.id.tv_widowmanager) TextView mTv_windowManager;
    @Bind(R.id.tv_fly) TextView mTv_fly;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        ButterKnife.bind(this);

        initEvent();
        initData();
    }

    private void initEvent(){
        mTv_canvas_draw.setOnClickListener(this);
        mTv_marqueeview.setOnClickListener(this);
        mTv_numberprogress.setOnClickListener(this);
        mTv_mycardview.setOnClickListener(this);
        mTv_flowlayout_view.setOnClickListener(this);
        mTv_display_view.setOnClickListener(this);
        mTv_customImage_view.setOnClickListener(this);
        mTv_animation_loading.setOnClickListener(this);
        mTv_windowManager.setOnClickListener(this);
        mTv_fly.setOnClickListener(this);
    }

    private void initData(){

        mTv_argument.setText(String.format(
                getString(R.string.argement)
                        , DisplayUtil.getWindowWidth(this)
                        , DisplayUtil.getWindowHeight(this)
                        , DisplayUtil.getWindowDensity(this)
        ,  DisplayUtil.getWindowDensityDpi(this)));


        mTv_notice.init(getWindowManager());
        mTv_notice.startScroll();

        Log.d(TAG, "initData: getWindowWidth="
                + DisplayUtil.getWindowWidth(this)
                +",getHeight="+DisplayUtil.getWindowHeight(this));
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.tv_widowmanager:
                startActivity(new Intent(this, TsWindowMangerActivity.class));
                break;
            case R.id.tv_fly:
                startActivity(new Intent(this, FlyAnimatorActivity.class));
                break;
            case R.id.tv_canvas_draw:
                startActivity(new Intent(this, TsCanvasActivity.class));
                break;
            case R.id.tv_marguee_view:
                startActivity(new Intent(this, MarqueeActivity.class));
                break;
            case R.id.tv_numberProgress_view:
                startActivity(new Intent(this, NumberProgressActivity.class));
                break;
            case R.id.tv_mycard_view:
                startActivity(new Intent(this, MyCardActivity.class));
                break;
            case R.id.tv_flowlayout_view:
                startActivity(new Intent(this, FlowLayoutActivity.class));
                break;
            case R.id.tv_display_view:
                startActivity(new Intent(this, DisplayShotActivity.class));
                break;
            case R.id.tv_customimage_view:
                startActivity(new Intent(this, CustomImageActivity.class));
                break;
            case R.id.tv_animation_loading:
                startActivity(new Intent(this, LoadingAnimaActivity.class));
                break;
            default:
                break;
        }
    }









}
